cmake_minimum_required(VERSION 3.16)

project(LevelForSteel VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.4 REQUIRED COMPONENTS Sql Core  HttpServer Concurrent Quick Qml Network HttpServer Widgets)

qt_standard_project_setup()

qt_add_executable(appLevelForSteel
    main.cpp
)

qt_add_qml_module(appLevelForSteel
    URI LevelForSteel
    VERSION 1.0
    QML_FILES
        Main.qml
        SOURCES src/Utils/dbconnhelper.h src/Utils/dbconnhelper.cpp
        SOURCES src/Utils/inifilehelper.h src/Utils/inifilehelper.cpp
        SOURCES src/Utils/jsonfilehelper.h src/Utils/jsonfilehelper.cpp
        SOURCES src/Models/NormalDefectModels.h
        SOURCES src/Thread/threadbase.h src/Thread/threadbase.cpp
        SOURCES src/Entity/clientdefect.h src/Entity/clientdefect.cpp
        SOURCES src/CORPattern/handleinterface.h src/CORPattern/handleinterface.cpp
        SOURCES src/Thread/timerhandleseq.h src/Thread/timerhandleseq.cpp
        SOURCES src/Models/steelserverresponse.h src/Models/steelserverresponse.cpp
        SOURCES src/Strategypatttern/strategycontenxtbase.h src/Strategypatttern/strategycontenxtbase.cpp
        SOURCES src/Strategypatttern/strategyconditionbase.h src/Strategypatttern/strategyconditionbase.cpp
        SOURCES src/Sock/defectdatatcpclient.h src/Sock/defectdatatcpclient.cpp
        SOURCES src/Strategypatttern/threelevelconditiondetect.h src/Strategypatttern/threelevelconditiondetect.cpp
        SOURCES src/Strategypatttern/twolevelconditiondetect.h src/Strategypatttern/twolevelconditiondetect.cpp
        SOURCES src/Strategypatttern/onelevelconditiondetect.h src/Strategypatttern/onelevelconditiondetect.cpp
        SOURCES src/Utils/defectlevelmap.h src/Utils/defectlevelmap.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appLevelForSteel PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appLevelForSteel
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

#添加库
find_library(X_LIB NAMES XuanCommon PATHS ${CMAKE_SOURCE_DIR}/include) #库路径
include_directories(${CMAKE_SOURCE_DIR}/include) #头文件


target_link_libraries(appLevelForSteel
    PRIVATE
    Qt6::Sql
    ${X_LIB}
    Qt6::Core
    Qt6::HttpServer
    Qt6::Concurrent
    Qt6::Quick
    Qt6::Qml
    Qt6::Network
    Qt6::HttpServer
    Qt6::Widgets
)

include(GNUInstallDirs)
install(TARGETS appLevelForSteel
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
